//
//  QDOrderTableViewCell.m
//  qidianchelian
//
//  Created by 冯贺 on 2018/4/20.
//  Copyright © 2018年 冯贺. All rights reserved.
//

#import "QDOrderTableViewCell.h"

@implementation QDOrderTableViewCell{
    UIImageView * _shopImg;
    UILabel * _titleL;
    UILabel * _status;
    UILabel * _timeL;
    UILabel * _moneyL;
    UILabel * _orderIdL;
    UIButton * _payBtn;
    
}

- (void)setFrame:(CGRect)frame{
    frame.origin.x += 15*bili;
    frame.origin.y += 20*bili;
    frame.size.height -= 20*bili;
    frame.size.width -= 30*bili;
    [super setFrame:frame];
}


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setUI];
    }
    return self;
}
-(void)setUI{
    UIView * backView = [[UIView alloc]init];
    backView.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:backView];
    
    _shopImg = [[UIImageView alloc]init];
    _shopImg.image = [UIImage imageNamed:@"图片"];
    [backView addSubview:_shopImg];
    
    _titleL = [[UILabel alloc]initWithTitle:@"启点车联行车记录仪" font:16*bili color:kBlackColor];
    [backView addSubview:_titleL];
    
    _status = [[UILabel alloc]initWithTitle:@"待支付" font:14*bili color:kLabelColor];
    _status.textAlignment = 2;
    [backView addSubview:_status];
    
    _timeL = [[UILabel alloc]initWithTitle:@"2018-04-21 12:35:23" font:13*bili color:kLabelColor];
    [backView addSubview:_timeL];
    
    _moneyL = [[UILabel alloc]initWithTitle:@"¥99.0" font:13*bili color:[UIColor redColor]];
    _moneyL.textAlignment = 2;
    [backView addSubview:_moneyL];
    
    UILabel * lineL = [[UILabel alloc]init];
    lineL.backgroundColor = kLightGrayColor;
    [backView addSubview:lineL];
    
    _orderIdL = [[UILabel alloc]initWithTitle:@"订单号: 3244878731924" font:14*bili color:kLabelColor];
    [backView addSubview:_orderIdL];
    
    _payBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [_payBtn addTarget:self action:@selector(payClick) forControlEvents:UIControlEventTouchUpInside];
    _payBtn.layer.cornerRadius = 4*bili;
    _payBtn.layer.borderColor = kBlueColor.CGColor;
    _payBtn.layer.borderWidth = 1;
    [_payBtn setTitle:@"去支付" forState:0];
    [backView addSubview:_payBtn];
    
    backView.sd_layout
    .leftEqualToView(self.contentView)
    .topEqualToView(self.contentView)
    .widthRatioToView(self, 1)
    .heightRatioToView(self.contentView, 1);
    backView.clipsToBounds = YES;
    backView.layer.cornerRadius = 6*bili;

    _shopImg.sd_layout
    .leftSpaceToView(backView, 15*bili)
    .topSpaceToView(backView, 15*bili)
    .widthIs(80*bili)
    .heightEqualToWidth();
    
    _titleL.sd_layout
    .leftSpaceToView(_shopImg, 15*bili)
    .topSpaceToView(backView, 25*bili)
    .widthIs(200*bili)
    .heightIs(20*bili);
    
    _status.sd_layout
    .rightSpaceToView(backView, 20*bili)
    .centerYEqualToView(_titleL)
    .widthIs(80*bili)
    .heightIs(15*bili);
    
    _timeL.sd_layout
    .leftEqualToView(_titleL)
    .topSpaceToView(_titleL, 20*bili)
    .widthIs(160*bili)
    .heightIs(15*bili);
    
    _moneyL.sd_layout
    .rightEqualToView(_status)
    .centerYEqualToView(_timeL)
    .widthIs(100*bili)
    .heightIs(15*bili);
    
    lineL.sd_layout
    .leftEqualToView(_shopImg)
    .topSpaceToView(_shopImg, 15*bili)
    .rightSpaceToView(backView, 20*bili)
    .heightIs(1);
    
    _orderIdL.sd_layout
    .leftEqualToView(_shopImg)
    .topSpaceToView(lineL, 20*bili)
    .widthIs(250*bili)
    .heightIs(15*bili);
    
    _payBtn.sd_layout
    .rightEqualToView(_status)
    .centerYEqualToView(_orderIdL)
    .widthIs(90*bili)
    .heightIs(30*bili);
}
-(void)payClick{
    if (self.payBlock) {
        self.payBlock();
    }
}
@end
